home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / ifcico / dietifna.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-09  |  2.1 KB  |  99 lines

  1. #include <stdlib.h>
  2. #include "lutil.h"
  3. #include "ttyio.h"
  4. #include "session.h"
  5. #include "emsi.h"
  6.  
  7. extern int made_request;
  8. static int sendfiles(file_list*);
  9. extern int xmsndfiles(file_list*);
  10. static int xmrcvfiles(void);
  11. extern int xmrecv(char*);
  12. extern file_list *respond_wazoo(char*);
  13.  
  14. int rxdietifna(void);
  15. int rxdietifna(void)
  16. {
  17.     int rc;
  18.     file_list *tosend=NULL,**tmpfl;
  19.  
  20.     debug(10,"start rxDietIFNA");
  21.     session_flags |= SESSION_IFNA;
  22.     session_flags &= ~SESSION_BARK;
  23.     tosend=create_filelist(remote,ALL_MAIL,0);
  24.     if ((rc=xmrcvfiles()) == 0)
  25.     {
  26.         if ((emsi_local_opts & NRQ) == 0)
  27.         {
  28.             for (tmpfl=&tosend;*tmpfl;tmpfl=&((*tmpfl)->next));
  29.             *tmpfl=respond_wazoo(NULL);
  30.         }
  31.         rc=sendfiles(tosend);
  32.         /* we are not sending file requests in slave session */
  33.     }
  34.     tidy_filelist(tosend,(rc == 0));
  35.     debug(10,"rxdietifna transfer rc=%d",rc);
  36.     return rc;
  37. }
  38.  
  39. int txdietifna(void);
  40. int txdietifna(void)
  41. {
  42.     int rc;
  43.     file_list *tosend=NULL,*respond=NULL;
  44.     char *nonhold_mail;
  45.  
  46.     debug(10,"start txDietIFNA");
  47.     session_flags |= SESSION_IFNA;
  48.     session_flags &= ~SESSION_BARK;
  49.     if (localoptions & NOHOLD) nonhold_mail=ALL_MAIL;
  50.     else nonhold_mail=NONHOLD_MAIL;
  51.     tosend=create_filelist(remote,nonhold_mail,2);
  52.  
  53.     if ((rc=sendfiles(tosend)) == 0)
  54.         if ((rc=xmrcvfiles()) == 0)
  55.             if ((emsi_local_opts & NRQ) == 0)
  56.                 if ((respond=respond_wazoo(NULL)))
  57.                     rc=sendfiles(respond);
  58.     /* but we are trying to respond other's file requests in master */
  59.     /* session, though they are not allowed by the DietIFNA protocol */
  60.     
  61.     tidy_filelist(tosend,(rc == 0));
  62.     tidy_filelist(respond,0);
  63.     debug(10,"rxdietifna transfer rc=%d",rc);
  64.     return rc;
  65. }
  66.  
  67. int xmrcvfiles(void)
  68. {
  69.     int rc;
  70.  
  71.     while ((rc=xmrecv(NULL)) == 0);
  72.     if (rc == 1) return 0;
  73.     else return rc;
  74. }
  75.  
  76. int sendfiles(tosend)
  77. file_list *tosend;
  78. {
  79.     int c,count;
  80.  
  81.     count=0;
  82.     while (((c=GETCHAR(15)) >= 0) && (c != NAK) && (c != 'C') && 
  83.            (count++ < 9)) 
  84.         debug(11,"got '%s' waiting for C/NAK",
  85.             printablec(c));
  86.     if (c == NAK)
  87.     {
  88.         session_flags &= ~FTSC_XMODEM_CRC;
  89.     }
  90.     else if (c == 'C')
  91.     {
  92.         session_flags |= FTSC_XMODEM_CRC;
  93.     }
  94.     else if (c < 0) return c;
  95.     else return 1;
  96.  
  97.     return xmsndfiles(tosend);
  98. }
  99.